package one.three.web.ten;

public class Palindrome {

	public static boolean palindrome(String str) {
		
		Stack<Character> s = new Stack<Character>();
		Queue<Character> q = new Queue<Character>();
		char c;
		for (int i = 0; i < str.length(); i++) {
			c = str.charAt(i);
			if (c == ' ' || c == ',' || c == '-') {
				continue;
			}
			s.push(c);
			q.enqueue(c);
		}
		//System.out.println("s:"+s);
		//System.out.println("q:"+q);
		char c1, c2;
		while (!s.isEmpty()) {
			c1 = s.pop();
			c2 = q.dequeue();
			if (c1 != c2)
				return false;
		}

		return true;
	}

	public static void main(String[] args) {
		System.out.println(palindrome("a man,a plan,a canal-panamas"));

	}

}
